package com.sxfq.loansupermarket.backsystem.modular.report.controller;

import com.baomidou.mybatisplus.plugins.Page;
import com.sxfq.loansupermarket.backsystem.common.constant.factory.PageFactory;
import com.sxfq.loansupermarket.backsystem.common.controller.BaseController;
import com.sxfq.loansupermarket.backsystem.modular.arrival.service.ICustomerService;
import com.sxfq.loansupermarket.backsystem.modular.base.SqlMapper;
import com.sxfq.loansupermarket.backsystem.modular.report.entity.SevenReportInfo;
import com.sxfq.loansupermarket.backsystem.modular.report.entity.WholeHospitalsInfo;
import com.sxfq.loansupermarket.backsystem.modular.report.service.ISevenReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.List;

/**
 * 预约客户信息
 *
 * @author py
 * @Date 2018年4月19日23:15:54
 */
@Controller
@RequestMapping("/sevenReport")
public class SevenReportController extends BaseController {

    @Autowired
    ISevenReportService service;

    @Autowired
    ICustomerService customerService;

    @Autowired
    private SqlMapper sqlMapper;

    private String PREFIX = "/report/wholeHospital/";

    /**
     * 跳转到考试列表
     */
    @RequestMapping("/list")
    @ResponseBody
    public Object list(SevenReportInfo searchInfo, HttpServletRequest request) {
        Page<WholeHospitalsInfo> page = new PageFactory<WholeHospitalsInfo>().defaultPage();
        try {
            List<WholeHospitalsInfo> list = new ArrayList<WholeHospitalsInfo>();
            if("department".equals(searchInfo.getDimensionSelection())) {
                if ("customerAge".equals(searchInfo.getDimensionSelections())) {
                    list = service.getCustomerAgeList(searchInfo);
                } else if ("tcName".equals(searchInfo.getDimensionSelections())) {
                    list = service.getTcNameList(searchInfo);
                } else if ("medium".equals(searchInfo.getDimensionSelections())) {
                    list = service.getOneMediumList(searchInfo);
                } else if ("doctor".equals(searchInfo.getDimensionSelections())) {
                    list = service.getDoctorList(searchInfo);
                }  else if ("cities".equals(searchInfo.getDimensionSelections())) {
                    list = service.getCitiesList(searchInfo);
                } else if ("channel".equals(searchInfo.getDimensionSelections())) {
                    list = service.getOneChannelList(searchInfo);
                } else if ("occupation".equals(searchInfo.getDimensionSelections())) {
                    list = service.getOccupation(searchInfo);
                }
            }
            if("customerAge".equals(searchInfo.getDimensionSelection())) {
                searchInfo.setDimensionSelection("age_range");
                if ("department".equals(searchInfo.getDimensionSelections())) {
                    list = service.getDepartment(searchInfo);
                } else if ("tcName".equals(searchInfo.getDimensionSelections())) {
                    list = service.getTcNameList(searchInfo);
                } else if ("medium".equals(searchInfo.getDimensionSelections())) {
                    list = service.getOneMediumList(searchInfo);
                } else if ("doctor".equals(searchInfo.getDimensionSelections())) {
                    list = service.getDoctorList(searchInfo);
                } else if ("cities".equals(searchInfo.getDimensionSelections())) {
                    list = service.getCitiesList(searchInfo);
                } else if ("channel".equals(searchInfo.getDimensionSelections())) {
                    list = service.getOneChannelList(searchInfo);
                } else if ("occupation".equals(searchInfo.getDimensionSelections())) {
                    list = service.getOccupation(searchInfo);
                }
            }
            if("tcName".equals(searchInfo.getDimensionSelection())) {
                searchInfo.setDimensionSelection("field_tc");
                if ("department".equals(searchInfo.getDimensionSelections())) {
                    list = service.getDepartment(searchInfo);
                } else if ("customerAge".equals(searchInfo.getDimensionSelections())) {
                    list = service.getCustomerAgeList(searchInfo);
                } else if ("medium".equals(searchInfo.getDimensionSelections())) {
                    list = service.getOneMediumList(searchInfo);
                } else if ("doctor".equals(searchInfo.getDimensionSelections())) {
                    list = service.getDoctorList(searchInfo);
                }  else if ("cities".equals(searchInfo.getDimensionSelections())) {
                    list = service.getCitiesList(searchInfo);
                } else if ("channel".equals(searchInfo.getDimensionSelections())) {
                    list = service.getOneChannelList(searchInfo);
                } else if ("occupation".equals(searchInfo.getDimensionSelections())) {
                    list = service.getOccupation(searchInfo);
                }
            }
            if("medium".equals(searchInfo.getDimensionSelection())) {
                searchInfo.setDimensionSelection("one_medium");
                if ("department".equals(searchInfo.getDimensionSelections())) {
                    list = service.getDepartment(searchInfo);
                } else if ("customerAge".equals(searchInfo.getDimensionSelections())) {
                    list = service.getCustomerAgeList(searchInfo);
                } else if ("tcName".equals(searchInfo.getDimensionSelections())) {
                    list = service.getTcNameList(searchInfo);
                } else if ("doctor".equals(searchInfo.getDimensionSelections())) {
                    list = service.getDoctorList(searchInfo);
                } else if ("cities".equals(searchInfo.getDimensionSelections())) {
                    list = service.getCitiesList(searchInfo);
                } else if ("channel".equals(searchInfo.getDimensionSelections())) {
                    list = service.getOneChannelList(searchInfo);
                } else if ("occupation".equals(searchInfo.getDimensionSelections())) {
                    list = service.getOccupation(searchInfo);
                }
            }
            if("doctor".equals(searchInfo.getDimensionSelection())) {
                if ("department".equals(searchInfo.getDimensionSelections())) {
                    list = service.getDepartment(searchInfo);
                } else if ("customerAge".equals(searchInfo.getDimensionSelections())) {
                    list = service.getCustomerAgeList(searchInfo);
                } else if ("tcName".equals(searchInfo.getDimensionSelections())) {
                    list = service.getTcNameList(searchInfo);
                } else if ("medium".equals(searchInfo.getDimensionSelections())) {
                    list = service.getOneMediumList(searchInfo);
                } else if ("cities".equals(searchInfo.getDimensionSelections())) {
                    list = service.getCitiesList(searchInfo);
                } else if ("channel".equals(searchInfo.getDimensionSelections())) {
                    list = service.getOneChannelList(searchInfo);
                } else if ("occupation".equals(searchInfo.getDimensionSelections())) {
                    list = service.getOccupation(searchInfo);
                }
            }
            if("cities".equals(searchInfo.getDimensionSelection())) {
                if ("department".equals(searchInfo.getDimensionSelections())) {
                    list = service.getDepartment(searchInfo);
                } else if ("customerAge".equals(searchInfo.getDimensionSelections())) {
                    list = service.getCustomerAgeList(searchInfo);
                } else if ("tcName".equals(searchInfo.getDimensionSelections())) {
                    list = service.getTcNameList(searchInfo);
                } else if ("medium".equals(searchInfo.getDimensionSelections())) {
                    list = service.getOneMediumList(searchInfo);
                } else if ("doctor".equals(searchInfo.getDimensionSelections())) {
                    list = service.getDoctorList(searchInfo);
                }  else if ("channel".equals(searchInfo.getDimensionSelections())) {
                    list = service.getOneChannelList(searchInfo);
                } else if ("occupation".equals(searchInfo.getDimensionSelections())) {
                    list = service.getOccupation(searchInfo);
                }
            }
            if("channel".equals(searchInfo.getDimensionSelection())) {
                searchInfo.setDimensionSelection("one_channel");
                if ("department".equals(searchInfo.getDimensionSelections())) {
                    list = service.getDepartment(searchInfo);
                } else if ("customerAge".equals(searchInfo.getDimensionSelections())) {
                    list = service.getCustomerAgeList(searchInfo);
                } else if ("tcName".equals(searchInfo.getDimensionSelections())) {
                    list = service.getTcNameList(searchInfo);
                } else if ("medium".equals(searchInfo.getDimensionSelections())) {
                    list = service.getOneMediumList(searchInfo);
                } else if ("doctor".equals(searchInfo.getDimensionSelections())) {
                    list = service.getDoctorList(searchInfo);
                }  else if ("department".equals(searchInfo.getDimensionSelections())) {
                    list = service.getDepartment(searchInfo);
                } else if ("occupation".equals(searchInfo.getDimensionSelections())) {
                    list = service.getOccupation(searchInfo);
                }
            }
            if("occupation".equals(searchInfo.getDimensionSelection())) {
                if ("department".equals(searchInfo.getDimensionSelections())) {
                    list = service.getDepartment(searchInfo);
                } else if ("customerAge".equals(searchInfo.getDimensionSelections())) {
                    list = service.getCustomerAgeList(searchInfo);
                } else if ("tcName".equals(searchInfo.getDimensionSelections())) {
                    list = service.getTcNameList(searchInfo);
                } else if ("medium".equals(searchInfo.getDimensionSelections())) {
                    list = service.getOneMediumList(searchInfo);
                } else if ("doctor".equals(searchInfo.getDimensionSelections())) {
                    list = service.getDoctorList(searchInfo);
                }  else if ("department".equals(searchInfo.getDimensionSelections())) {
                    list = service.getDepartment(searchInfo);
                } else if ("channel".equals(searchInfo.getDimensionSelections())) {
                    list = service.getOneChannelList(searchInfo);
                }
            }
            page.setRecords(list);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return super.packForBT(page);
    }

}
